﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using KhachSan.Process.Private.Tien.Usercontrol;

namespace KhachSan.Process.Private.Tien
{
    public partial class F_Main : Form
    {
        public F_Main()
        {
            InitializeComponent();
            float WidthScreen = Screen.PrimaryScreen.Bounds.Width;
            float WidthLabel = lblKS.Width;
            lblKS.Left = (int) Math.Round(WidthScreen/2 - WidthLabel/2);

            //gửi vào quyền khi gọi usercontrol lun
            ucMenu menu = new ucMenu(pCenter, pBack,lblKS,pPic);
            menu.Dock = DockStyle.Fill;
            pCenter.Controls.Add(menu);
            pBack.Visible = false;
        }
        #region Giao diện Top Bot

        private void panel3_MouseHover_1(object sender, EventArgs e)
        {
            pBack.BackgroundImage = Image.FromFile(Application.StartupPath + "/hinh_Tien/left_round-48-white.png");
        }

        private void panel3_MouseLeave_1(object sender, EventArgs e)
        {
            pBack.BackgroundImage = Properties.Resources.left_round_48;
        }

        private void panel1_MouseHover(object sender, EventArgs e)
        {
            pHome.BackgroundImage =
                Image.FromFile(Application.StartupPath + "/hinh_Tien/080053-flat-gray-floral-icon-business-home6.png");
        }

        private void panel1_MouseLeave(object sender, EventArgs e)
        {
            pHome.BackgroundImage = Properties.Resources._080052_flat_gray_floral_icon_business_home5;
        }

        private void panel2_MouseHover(object sender, EventArgs e)
        {
            pExit.BackgroundImage = Image.FromFile(Application.StartupPath + "/hinh_Tien/exit.png");
        }

        private void panel2_MouseLeave(object sender, EventArgs e)
        {
            pExit.BackgroundImage = Properties.Resources.exit;
        }

        private void panel5_MouseHover(object sender, EventArgs e)
        {
            pSetting.BackgroundImage = Image.FromFile(Application.StartupPath + "/hinh_Tien/settings-64.png");
        }

        private void panel5_MouseLeave(object sender, EventArgs e)
        {
            pSetting.BackgroundImage = Properties.Resources.settings_64;
        }

        #endregion

        private void pExit_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void pHome_Click(object sender, EventArgs e)
        {
            ThuVien.lBack.Clear();
            pCenter.Controls.Clear();
            ucMenu menu = new ucMenu(pCenter,pBack,lblKS,pPic);
            menu.Dock = DockStyle.Fill;
            pCenter.Controls.Add(menu);
            pBack.Visible = false;
            lblKS.Visible = true;
            pPic.Visible = true;
        }

        private void pBack_Click(object sender, EventArgs e)
        {
            pCenter.Controls.Clear();
            int sl = ThuVien.lBack.Count;
            UserControl uc = ThuVien.lBack[sl - 1];
            if (uc.Name == "ucFormCheckIn_Hoi")
            {
                uc.Location = new Point(Screen.PrimaryScreen.Bounds.Width / 2 - uc.Size.Width / 2, Screen.PrimaryScreen.Bounds.Height / 2 - uc.Size.Height);
                pCenter.Controls.Add(uc);
                ThuVien.lBack.RemoveAt(sl - 1);
                if (ThuVien.lBack.Count == 0)
                {
                    pBack.Visible = false;
                    lblKS.Visible = true;
                    pPic.Visible = true;
                }    
            }
            else
            {
                uc.Dock = DockStyle.Fill;
                pCenter.Controls.Add(uc);
                ThuVien.lBack.RemoveAt(sl - 1);
                if (ThuVien.lBack.Count == 0)
                {
                    pBack.Visible = false;
                    lblKS.Visible = true;
                    pPic.Visible = true;
                }    
            }
        }
        
    }
}
